import Vue from "vue";
import VueRouter from "vue-router";
import About from "../views/About";
import Home from "../views/Home";
import Message from "../views/About/Message";
import News from "../views/About/News";
import Detail from "../views/About/Message/Detail";
// 使用插件
Vue.use(VueRouter);
export default new VueRouter({
  // 配置路由
  routes: [
    {
      path: "/about",
      component: About,
      children: [
        {
          path: "/about/news",
          component: News,
        },
        {
          path: "/about/message",
          component: Message,
          children: [
            {
              path: "/about/message/detail/:id", //匹配多个路径，必须传参
              component: Detail,
            },
            {
              path: "",
              redirect: "detail/1",
            },
          ],
        },
        {
          path: "",
          redirect: "message",
        },
      ],
    },
    {
      path: "/home",
      component: Home,
    },
    // {
    //   // 除了上面的路由匹配不了都会到这个页面来
    //   path: "*",
    //   redirect: "/home",
    // },
  ],
});
